<template>
	<view>
	<scroll-view scroll-y>
		<view class="cu-timeline" v-for="(item,index) in list" :key="index"  >
			<view class="cu-time">{{item.time}}</view>
			<view class="cu-item">
				<view class="content">
					<view class="cu-capsule radius">
							
							<view style="display: flex;flex-direction: column;">
								<view class="cu-tag line-yellow margin-right-sm">
								<text >昵称：{{item.nickName}}</text>
								</view>
								<view style="display: flex;flex-direction: row;">
									<text >活动：{{item.name}}</text>
									<button class="margin-left cu-btn sm" 
											:data-tag="item.id" 
											 v-if="item.nickName===nickName"
										 :class="['bg-yellow', 'shadow']"  @tap="deldata" :loading="loading" >删除</button>
								</view>
								<text >持续时间：{{item.duration}}</text>
								<text >持续次数：{{item.count}}</text>
							</view>
							
					</view>
					<view>学习收获：{{item.description}}</view>
				</view>
				</view>
				</view>
				<view class="margin-bottom-lg"></view>
				</scroll-view>
		</view>
		
</template>

<script>
	export default {
		data() {
			return {
				list:[],
				loading:false,
				nickName:'',
			};
		},
		created() {
			let that = this;
			// let str = 	    uni.getStorageSync("mypoolList");
			this.nickName = uni.getStorageSync("nickName");
			uni.request({
				 // url:"http://localhost:8081/service/findAll",
				url:"/service/findAll",
				method:"GET",
				success(resp) {
					// console.log('time created resp',resp)
					that.list = resp.data.list;
				}
			})
		},
		methods:{
			deldata(e){
				// console.log(e.currentTarget.dataset.tag)
				uni.request({
					 // url:"http://localhost:8081/service/delete",
					url:"/service/delete",
					method:"DELETE",
					data: {
						id: e.currentTarget.dataset.tag
					},
					success(resp) {
						// console.log(resp);
						window.location.reload();
						// that.list = resp.data.list;
					}
				})
			}
		}
	}
</script>

<style>
.page{
		background-color: white;
	}
	
	<style>
	.cu-capsule .cu-tag {
		border-right: 1rpx solid #fbbd08;
		border: 1rpx solid #fbbd08;
	}
	.cu-tag {
		border-right: 1rpx solid #fbbd08;
		border: 1rpx solid #fbbd08;
	}
</style>
